// import proFetch from "../../../../../public/functions/project-fetch";
import { hrAjax as ajax } from 'src/hrpub/common/utils/utils';
import updateButtonStatus from './updateButtonStatus';
import getMainTableData from './getMainTableData';
import getOneAgreementInfo from './getOneAgreementInfo';
import handleAllpks from './handleAllpks';
import { cacheTools, toast } from 'nc-lightapp-front';
// import { async } from 'q';

export default function deleteAgreementData() {

	const { deletePks, agreementType, orgVal, editPk, pageFlag } = this.state;
	return ajax({
		url: '/nccloud/hrcm/agreement/ChangeDelAction.do',
		body: {
			pk_agreements: deletePks
		}
	}).then((res) => {
		if (res.success) {
			if (pageFlag === 'list') {
				getMainTableData.call(this);
			} else if (pageFlag === 'card') {
                let getnextPk = handleAllpks.getNextPk(deletePks[0]);
                this.setState({
                    editPk: getnextPk,
                },()=>{
                    handleAllpks.remove(deletePks[0]); // 更新卡片分页主键
                    getOneAgreementInfo.call(this);
                });
			}
			updateButtonStatus.call(this, orgVal, agreementType);
			toast({ color: 'success', content: res.data.msg });
		}
	});
}
